package jc.malpractice.db;

import com.microsoft.sqlserver.jdbc.SQLServerDataSource;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MsSqlUtil {
    public static SQLServerDataSource mssqlSource = null;
    static{
        mssqlSource = new SQLServerDataSource();
        mssqlSource.setUser("pacs");
        mssqlSource.setPassword("pacs");
        mssqlSource.setServerName("172.16.88.99");
        mssqlSource.setPortNumber(Integer.parseInt("1433"));
        mssqlSource.setDatabaseName("REPORT");

    }

    public static void close(Connection connection, Statement statement, ResultSet resultSet){
        if (resultSet != null){
            try {
                resultSet.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if (statement != null){
            try {
                statement.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
        if (connection != null){
            try {
                connection.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }


}